package com.action;

import com.entity.User;
import com.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;


import java.util.List;

@Controller
@Scope("prototype")
public class UserAction {
    @Autowired
    private UserService userService;
    private List<User> list;
    private String userName;
    private String password;

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public List<User> getList() {
        return list;
    }

    public void setList(List<User> list) {
        this.list = list;
    }
    public String selectAll(){
        list=userService.selectAll();
        System.out.println(list);
        return "showAll";
    }
    public String selectOne(){
        User user=userService.selectOne(userName,password);
        if (user!=null){

            return "loginSuccess";
        }else{
            return "loginError";
        }
    }
}
